package r21118d1123;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Demo03List03 {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.add("5");
        list.add("5");
        //增强For
        System.out.println("//增强For----------------");
        for (Object o :list){
            System.out.println(o+"-*-"+o);
        }
        //集合的forEach()方法
        System.out.println("集合的forEach()方法----------------");
        list.forEach(s-> System.out.println(s+"-*-"+s));
        //迭代器
        System.out.println("迭代器----------------");
        Iterator it = list.iterator();
        while(it.hasNext()){
            System.out.println(it.next()+"-*-"+it.next());
        }
        //传统for循环遍历
        System.out.println("传统for循环遍历----------------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i)+"-*-"+list.get(i));
        }
    }
}
